<extend name="Public/base" />

<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>{$meta_title}</h2>
    </div>
    <div class="cf">
        <div class="fl">
            <form action="{:U('index')}" method="POST">
                <!--<input type="text" name="keywords" class="text input-2x" value="{:I('keywords')}" placeholder="注册手机号/昵称">-->
                <select name="status">
                    <option value="-1" selected>是否禁用</option>
                    <option value ="0" <?php if(isset($status)&&$status==0){ echo 'selected';} ?>>正常</option>
                    <option value ="1" <?php if(isset($status)&&$status==1){ echo 'selected';} ?>>禁用</option>
                </select>
                <select name="is_ster">
                    <option value="-1" selected>是否绝育</option>
                    <option value ="0" <?php if(isset($is_ster)&&$is_ster==0){ echo 'selected';} ?>>否</option>
                    <option value ="1" <?php if(isset($is_ster)&&$is_ster==1){ echo 'selected';} ?>>是</option>
                </select>
                <select name="sheng" id="sheng">
                    <option value="-1" selected>请选择省</option>
                    <volist name="sheng_list" id="vo">
                        <option value="{$vo.id}" <?php if(isset($sheng)&&$sheng==$vo['id']){ echo 'selected';} ?>>{$vo.name}</option>
                    </volist>
                </select>
                <select name="shi" id="shi">
                    <option value="-1" selected>请选择市</option>
                    <volist name="shi_list" id="vo">
                        <option value="{$vo.id}" <?php if(isset($shi)&&$shi==$vo['id']){ echo 'selected';} ?>>{$vo.name}</option>
                    </volist>

                </select>
                <select name="qu" id="qu">
                    <option value="-1" selected>请选择区县</option>
                    <volist name="qu_list" id="vo">
                        <option value="{$vo.id}" <?php if(isset($qu)&&$qu==$vo['id']){ echo 'selected';} ?>>{$vo.name}</option>
                    </volist>

                </select>

                <input type="text" name="keywords" class="text input-4x" value="{$keywords}" placeholder="狗卡姓名/卡号/主人">


                <button class="btn" type="submit">筛选</button>
            </form>
        </div>

        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <!--                <input type="text" name="nickname" class="search-input" value="{:I('nickname')}" placeholder="请输入用户昵称或者ID">
                                <a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>-->
            </div>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
                <tr>
                    <th class="">头像</th>
                    <th class="">名字</th>
                    <th class="">性别</th>
                    <th class="">卡号</th>
                    <th class="">是否绝育</th>
                    <th class="">出生日期</th>
                    <th class="">体重</th>
                    <th class="">所在城市</th>
                    <th class="">主人</th>
                    <th class="">银两总值</th>
                    <th class="">状态</th>
                    <th class="">操作</th>
                </tr>
            </thead>
            <tbody>
            <notempty name="_list">
                <volist name="_list" id="vo">
                    <tr>
                        <td>
                            <img src="__ROOT__{$vo.dog_face}" height="50px" width="50px">
                        </td>
                        <td>{$vo.dog_name}</td>
                        <td><eq name="vo.dog_sex" value="0">女<else/>男 </eq></td>
                    <td>{$vo.card_number}</td>
                    <td><eq name="vo.is_ster" value="0">否<else/>是 </eq></td>
                    <td>{$vo.dog_brithday}</td>
                    <td>{$vo.dog_weight}</td>
                    <td>{$vo.province}-{$vo.city}-{$vo.district}</td>
                    <td>{$vo.nick_name}</td>
                    <td>{$vo.yuanbao}</td>
                    <td><eq name="vo.status" value="0">正常<else/>禁用 </eq></td>
                    <td><eq name="vo.status" value="0">
                        <a href="{:U('changeStatus',array('id'=>$vo['dog_id'],'s'=>1))}" class="ajax-get">禁用</a>
                    <else/>
                    <a href="{:U('changeStatus',array('id'=>$vo['dog_id'],'s'=>0))}" class="ajax-get">启用</a>
                    </eq>
                    <a href="{:U('info',array('id'=>$vo['dog_id']))}" class="">查看</a>
                    </td>
                    </tr>
                </volist>
                <else/>
                <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });

        $("#sheng").change(function () {
            var fid = $(this).val();
            if (fid !== -1) {
                $.post("{:U('getInfo')}", {fid: fid}, function (res) {
                    var tbody = "<option value='-1' selected>请选择市</option>";
                    $.each(res, function (n, value) {
                        var trs = "";
                        trs += "<option value='" + value.id + "'>" + value.name + "</option>";
                        tbody += trs;
                    });
                    $("#shi").empty();

                    $("#shi").append(tbody);

                });
            }

        });

        $("#shi").change(function () {
            var fid = $(this).val();
            if (fid !== -1) {
                $.post("{:U('getInfo')}", {fid: fid}, function (res) {
                    var tbody = "<option value='-1' selected>请选择区县</option>";
                    $.each(res, function (n, value) {
                        var trs = "";
                        trs += "<option value='" + value.id + "'>" + value.name + "</option>";
                        tbody += trs;
                    });
                    $("#qu").empty();

                    $("#qu").append(tbody);

                });
            }

        });

        //导航高亮
        highlight_subnav('{:U('Dog / index')}');
    </script>
</block>
